const buildOptions = (options) => {
	return options;
}
export const $page = {
	open: (params) => {
		let options = {
			url: ''
		};
		if (typeof params === 'string') {
			options.url = params;
		} else {
			options = Object.assign(options, params);
		}
		uni.navigateTo(buildOptions(options));
	},
	redirect: (params) => {
		let options = {
			url: ''
		};
		if (typeof params === 'string') {
			options.url = params;
		} else {
			options = Object.assign(options, params);
		}
		uni.redirectTo(buildOptions(options))
	},
	reLaunch: (params) => {
		let options = {
			url: ''
		};
		if (typeof params === 'string') {
			options.url = params;
		} else {
			options = Object.assign(options, params);
		}
		uni.reLaunch(buildOptions(options))
	},
	switch: (params) => {
		let options = {
			url: ''
		};
		if (typeof params === 'string') {
			options.url = params;
		} else {
			options = Object.assign(options, params);
		}
		uni.switchTab(buildOptions(options));
	},
	back: () => {
		let pages = getCurrentPages();
		if (pages.length == 1) {
			uni.switchTab({
				url:'/pages/index/index'
			})
		} else {
			uni.navigateBack()
		}
	}
}